/**
 * 参看管理员的停车场是否已创建，若创建则可以查看，若未创建则跳转停车场发布页面
 */
package controller;

import java.util.Map;

import hibernate.Adminstab;
import hibernate.AdminstabDAO;
import hibernate.Parkstab;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;

public class ParkShowCheck implements Action {
	
	private Parkstab parkstab;
	private Adminstab adminstab;
	

	public Parkstab getParkstab() {
		return parkstab;
	}


	public void setParkstab(Parkstab parkstab) {
		this.parkstab = parkstab;
	}


	public Adminstab getAdminstab() {
		return adminstab;
	}


	public void setAdminstab(Adminstab adminstab) {
		this.adminstab = adminstab;
	}

	public String execute() throws Exception {

		AdminstabDAO adminstabDAO=new AdminstabDAO();
		adminstabDAO.getSession().beginTransaction();
		try
		{
			ActionContext ctx = ActionContext.getContext();
			Map map = ctx.getSession();
			adminstab = (Adminstab)adminstabDAO.findByAccount(map.get("account")).get(0);
			parkstab = adminstab.getParkstab();
	
			
			if(parkstab != null){
				parkstab.getName();
			}
			//System.out.println(parkstab.getName());
			
		    
			
			
			//Integer id = parkstab.getUuid();
			//map.put("parkID", parkstab.getUuid());

			//adminstabDAO.attachDirty(adminstab);
			adminstabDAO.getSession().getTransaction().commit();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			adminstabDAO.getSession().close();
		}
		if(parkstab == null){
			return ERROR;
		}
		else 
			return SUCCESS;
	
	}
}
